<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/fabric@5.0.0/dist/fabric.min.js"></script>
</head>

<body>
    <img src="https://cdn.chime.me/image/fs/user-info/2022210/17/original_25227749-ddf7-42ae-8911-155bb14576c0.png"
        crossorigin="anonymous" alt="">
</body>
<script>
    let sourceImg = document.getElementsByTagName('img')[0]


    sourceImg.onload = () => {

        const width = sourceImg.width;
        const height = sourceImg.height;
        const canvas = new fabric.Canvas(null, { background: 'red', width, height })

        var imgInstance = new fabric.Image(sourceImg, {
            width, height
        });

        canvas.add(imgInstance);
        let url = canvas.toDataURL({ format: 'jpeg', quality: 0.9 })
        console.log('urlrul', url)
        let img = new Image()
        img.src = url
        document.body.appendChild(img)




    };
</script>

</html>